//
//  YZPigGroupDocBaseInfoVC.m
//  VET
//
//  Created by YZ on 2018/7/21.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZPigGroupDocBaseInfoVC.h"
#import "YZPigGroupDocBaseInfoCell.h"

@interface YZPigGroupDocBaseInfoVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) YZPigGroupDocBaseInfoViewModel *viewModel;

@property (nonatomic, strong) UITableView *contentTb;

@end

@implementation YZPigGroupDocBaseInfoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self configUI];
}

- (void)configUI
{
    [self.view addSubview:self.contentTb];
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.viewModel.dataSource.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.viewModel.dataSource[section].count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;
    static NSString *cellId = @"YZPigGroupDocBaseInfoCell";
    cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if(!cell){
        cell = [[YZPigGroupDocBaseInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    ((YZPigGroupDocBaseInfoCell *)cell).model = [self.viewModel modelInSection:indexPath.section row:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}


#pragma mark -- setters && getters

- (UITableView *)contentTb
{
    if(!_contentTb){
        _contentTb = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - (kStatusBarHeight + YZ_BOTTOM_MARGIN )) style:UITableViewStylePlain];
        _contentTb.estimatedRowHeight = 300;
        _contentTb.tableFooterView = [UIView new];
        _contentTb.delegate = self;
        _contentTb.dataSource = self;
    }
    return _contentTb;
}

- (YZPigGroupDocBaseInfoViewModel *)viewModel
{
    if(!_viewModel){
        _viewModel = [YZPigGroupDocBaseInfoViewModel new];
        _viewModel.model = self.model;
    }
    return _viewModel;
}

@end
